package com.lizhi.menu.controller;

import com.lizhi.menu.common.response.Result;
import com.lizhi.menu.domain.MenuType;
import com.lizhi.menu.service.IMenuTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * 菜谱类型Controller
 * 
 * @author lizhi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/system/type")
@Api(tags = "菜谱类型管理")
public class MenuTypeController
{
    @Autowired
    private IMenuTypeService menuTypeService;

    /**
     * 查询菜谱类型列表
     */
    @GetMapping("/list")
    @ApiOperation("查询菜谱类型列表")
    public Result list(MenuType menuType)
    {
        List<MenuType> list = menuTypeService.selectMenuTypeList(menuType);
        return Result.ok(list);
    }

 

    /**
     * 获取菜谱类型详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation("获取菜谱类型详细信息")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.ok(menuTypeService.selectMenuTypeById(id));
    }

    /**
     * 新增菜谱类型
     */
    @PostMapping
    @ApiOperation("新增菜谱类型")
    public Result add(@RequestBody MenuType menuType)
    {
        return Result.ok(menuTypeService.insertMenuType(menuType));
    }

    /**
     * 修改菜谱类型
     */
    @PutMapping
    @ApiOperation("修改菜谱类型")
    public Result edit(@RequestBody MenuType menuType)
    {
        return Result.ok(menuTypeService.updateMenuType(menuType));
    }

    /**
     * 删除菜谱类型
     */
	@DeleteMapping("/{ids}")
    @ApiOperation("删除菜谱类型")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.ok(menuTypeService.deleteMenuTypeByIds(ids));
    }
}
